#!/bin/sh
if [ -z $1 ];then
hive_db=default
else
hive_db=$1
fi

if [ -z $2 ];then
create_time=`date  "+%Y-%m-%d %H-%M-%S"`
else
create_time=$2
fi

hiveconfig=$(cat <<"EOF" /home/hdfs/parquet_shell/hive_parquet_scripts/hive.config
EOF
)

sql_suffix=$(cat <<EOF
        INSERT INTO TABLE dongfeng.navinfo_parquet_d00b PARTITION (part_time) SELECT latitude,longitude,originalLat,originalLng,height,direction,gpsDate,version,maintenanceEvent1,maintenanceEvent2,maintenanceEvent3,maintenanceEvent4,maintenanceEvent5,maintenanceEvent6,terminalId,serialNumber,'${create_time}',part_time FROM dongfeng.navinfo_stage_d00b;
EOF
)
sql="${hiveconfig}${sql_suffix}"
############  execute begin   ###########
hive --hiveconf "tez.queue.name=hive" -S -e "$sql"
#echo $sql
